<template>
  <el-form class="form-wrapper" ref="myForm" :model="myForm" label-width="110px">
    <el-form-item label="滑块验证：">
      <div><slider ref="slider"></slider></div>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="toSubmit">提交</el-button>
    </el-form-item>
  </el-form>
</template>
<script type="text/ecmascript-6">
  import slider from './slider'
  export default {
    data() {
      return {
        myForm: {}
      }
    },
    components: {
      slider
    },
    methods: {
      toSubmit() {
        if(this.$refs['slider']) {
          // 未通过验证时，提示错误信息并返回
          if (!this.$refs['slider'].confirmSuccess) {
            this.$message.error("请拖动滑块验证");
            return
          }
        }
        // 通过验证后提交
        // TO DO ...
        this.$message.success("验证成功，可提交");
      },
    }
  }
</script>
<style type="text/css" scoped>
  .form-wrapper {
    margin-top: 50px;
    width: 500px;
  }
</style>
